/*
 * Copyright (c) 2023 iQi.Co.Ltd. All rights reserved.
 */
 
using IQIGame.Onigao.Framework;
using System.Collections.Generic;
using System.Linq;
using System;
using NetProtocol.Enum;

namespace NetProtocol.POD {

	/// <summary>
	/// 
	/// module : level
	/// </summary>
	public class GetLevelSavePOD : IPOD 
    {
        public readonly static Func<GetLevelSavePOD> FACTORY = () => new GetLevelSavePOD();
		public static Func<GetLevelSavePOD> DynamicFactory = FACTORY;
        
		/*-- members --*/
		/// <summary>
        /// 注意, 每个服务器运行时类型不一样, 游戏服写入为bytes 客户端反序列bytes为LevelSavePOD
        /// </summary>
        public object saveData;
        public static Action<object, SOutputStream> Serial_saveData;
        public static Func<SInputStream, object> UnSerial_saveData;
		
		
		
		/*-- constructors --*/
		public GetLevelSavePOD() {}
		public GetLevelSavePOD(object saveData) {
			this.saveData = saveData;
		}
	      public void Serial(SOutputStream _out) {
            Serial_saveData.Invoke(saveData, _out);
        }
        
        public void UnSerial(SInputStream _in) {
            if(!_in.HasRemaining()) return;
            saveData = UnSerial_saveData.Invoke(_in);
        }
		
		public GetLevelSavePOD Clone() {
            GetLevelSavePOD o = DynamicFactory();
            o.saveData = saveData;
            return o;
        }
        
        public void Clear() {
            saveData = default;
        }
		
        public override string ToString() {
			string str = "";
			str += "GetLevelSavePOD [";
			str += "saveData=";
			str += saveData;
			str += "]";
			return str;
		}
		
	}
}